# 分析“https://fanyi.baidu.com/”百度翻译页面，要求用户在控制台输入需要翻译的单词给出翻译结果。
import requests
import json
fy = input("请输入您要翻译的词：")
url = 'https://fanyi.baidu.com/sug'
url1 = 'https://fanyi.baidu.com/v2transapi'
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"}
data = {
    "kw": fy,
    "from": "zh",
    "to": "en"
}
response = requests.post(url, data=data, headers=headers)
yf = response.content.decode()
dict_str = json.loads(yf)
str = dict_str["data"][0]["v"]
print(str)